<?php
/**
 * @author zhaofei
 * @package 系统登陆
 * @createtime 2014-11-25
 * @updatetime 2014-11-25
 * @ps:系统login
 */
namespace System\Controller;
use Think\Controller;
class LoginController extends Controller{
	
	public function index(){
		$this->display();
	}

	public function check(){
		$name = I('post.username',0,'htmlspecialchars');
		$password = I('post.password',0,'htmlspecialchars');
		$password = md5(md5($password,true));
		if(!$name){
			$this->error('请输入登陆姓名');
		}
		$rs = D('Employee')->findByAttr(array('true_name'=>$name,'password'=>$password,'status'=>1));
		$data = array();
		if($rs){
			$url = D('Employee')->saveLoginInfo($rs);
			$this->success('系统欢迎你',$url);
		}else{
			$this->error('用户名或密码错误');
		}
	}

	// 注销
	public function logout(){
		session('true_name',null);
		session('ranks',null);
		session('password',null);
		session_destroy();
		$this->success('欢迎下次再来',U('Login/index'));

	}
}

?>